#include "Queue.h"
#include "ChessNode.h"

using  namespace std;

Queue::Queue() {
        //  firstOne = new queueNode();
        //  lastOne = firstOne->next;
        firstOne = lastOne = NULL;
        size_ = 0;
    }

Queue::~Queue(){}


bool Queue::empty_()
{
    return (size_==0)?true:false;
}

void Queue::pop()
{
    if(size_== 1)
    {
        queueNode* temp = firstOne;
        firstOne = firstOne->next;
        lastOne = firstOne;
        delete temp;
        size_--;
    }
    else if(size_ == 0)
    {
        return;
    }
    else
    {
        queueNode* temp = firstOne;
        firstOne = firstOne->next;
        delete temp;
        size_--;
    }

}

void Queue::push(ChessNode* p)
{
    if(size_==0)
    {
        firstOne = lastOne = new queueNode(p);
        size_++;
    }
    else
    {
        lastOne->next = new queueNode(p);
        lastOne = lastOne->next;
        size_++;
    }
}

ChessNode* Queue::front_()
{
    return firstOne->chessnode;
}

ChessNode* Queue::back_()
{
    return lastOne->chessnode;
}

